package main.Q1701_1800;

public class Q1701_1710 {
    public static void main(String[] args) {
        System.out.println("Question1701：");
        System.out.println("Question1702：");
        System.out.println("Question1703：");
        System.out.println("Question1704：");
        System.out.println("Question1705：");
        System.out.println("Question1706：球会落何处");
        System.out.println("Question1707：");
        System.out.println("Question1708：");
        System.out.println("Question1709：");
        System.out.println("Question1710：");
    }
}

class Question1706{
    int[][] grid;
    public int process(int row,int col){
        if (row== grid.length) return col;//底部掉出
        if (col+1<grid[0].length&&grid[row][col]==1&&grid[row][col+1]==-1) return -1;//向右卡住
        if (grid[row][col]==1&&col== grid[0].length-1) return -1;//向右边界卡住
        if (col-1>=0&&grid[row][col]==-1&&grid[row][col-1]==1) return -1;//向左卡住
        if (grid[row][col]==-1&&col==0) return -1;//向左边界卡住
        int result=0;
        if (grid[row][col]==1) result=process(row+1,col+1);//右滑动
        else if (grid[row][col]==-1) result=process(row+1,col-1);//左滑动
        return result;
    }
    public int[] findBall(int[][] grid) {
        this.grid=grid;
        int[] result=new int[grid[0].length];
        for (int i=0;i< result.length;i++){
            int temp=process(0,i);
            result[i]=temp;
        }
        return result;
    }
}